import 'package:flutter/material.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'package:get/get.dart';

import '../../../r.dart';
import 'password_reset_logic.dart';

/**
 * @Description: 忘记密码
 * @Author: 下雨了
 * @CreateDate: 2022-5-23 10:26:02
 * @UpdateUser: 更新者
 * @UpdateDate:  2022-6-30 11:13:50
 * @UpdateRemark: getx
 * @Version: 1.1
 */
///
class PasswordResetPage extends StatefulWidget {
  final String title;

  const PasswordResetPage({Key? key, required this.title}) : super(key: key);

  @override
  _PasswordResetPageState createState() => _PasswordResetPageState();
}

class _PasswordResetPageState extends State<PasswordResetPage> {
  final logic = Get.put(PasswordResetLogic());
  final state = Get.find<PasswordResetLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PasswordResetLogic>(builder: (logic) {
      return Scaffold(
        // backgroundColor: MyColors.FFF1F1F1,
        appBar: MyAppBar(context, title: "忘记密码"),
        body: Column(
          children: [
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 20.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon44, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Text("+86", style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.userName,
                      autofocus: false,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请输入手机号码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                  ElevatedButton(
                    child: Text("获取验证码", style: TextStyle(color: Colors.white, fontSize: 13.sp),),
                    style: ElevatedButton.styleFrom(
                      padding: EdgeInsets.all(5.r),
                    ),
                    onPressed: () {
                      logic.getIdentifyingCode();
                    },
                  ),
                ],
              ),
            ),
            Divider(height: 0.5, thickness: 1, color: MyColors.FFF5F5F5,),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon41, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.smsCode,
                      autofocus: false,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请输入验证码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(height: 0.5, thickness: 1, color: MyColors.FFF5F5F5,),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon42, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.password,
                      autofocus: false,
                      obscureText: true,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请设置新密码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(height: 0.5, thickness: 1, color: MyColors.FFF5F5F5,),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 8.r, 20.r, 8.r),
              child: Row(
                children: [
                  Image.asset(R.assetsImgIcon43, width: 18.r,),
                  SizedBox(width: 10.r,),
                  Expanded(
                    child: TextField(
                      controller: logic.password2,
                      autofocus: false,
                      obscureText: true,
                      style: TextStyle(color: MyColors.FF999999, fontSize: 13.sp),
                      decoration: InputDecoration(
                        //不需要输入框下划线
                          border: InputBorder.none,
                          hintText: '请确认新密码',
                          hintStyle: TextStyle(color: MyColors.FF999999)),
                    ),
                  ),
                ],
              ),
            ),
            Divider(height: 0.5, thickness: 1, color: MyColors.FFF5F5F5,),
            Container(
              margin: EdgeInsets.fromLTRB(20.r, 90.r, 20.r, 0),
              height: 45.r,
              width: MediaQuery.of(context).size.width,
              child: ElevatedButton(
                child: Text("修改", style: TextStyle(color: MyColors.FFFFFFFF, fontSize: 14.sp),),
                style: ButtonStyle(
                  padding: MaterialStateProperty.all(EdgeInsets.all(0)),
                  backgroundColor: MaterialStateProperty.all<Color>(MyColors.FFE5261E),
                  shape:  MaterialStateProperty.all(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(5.r)),
                    ),
                  ),
                ),
                onPressed: () {
                  logic.retrieveLoginPassword();
                },
              ),
            ),
          ],
        ),

      );
    });
  }

  @override
  void dispose() {
    Get.delete<PasswordResetLogic>();
    super.dispose();
  }
}
